import React from 'react'
import { StyleSheet, Text, View, ActivityIndicator, Dimensions } from 'react-native';

const { width, height } = Dimensions.get('window');
_this = null;
export default class Loading extends React.Component {
    constructor (props) {
        super(props);
        _this = this;
        this.state = {
            show: false
        };
    }
    static show = () => {
        _this.setState({show: true});
    };
    static hide = () => {
        _this.setState({show: false});
    }
    render() {
        if(this.state.show) {
            return (
                <View style={styles.LoadingPage}>
                    <View style={{
                        width: 100,
                        height: 100,
                        backgroundColor: 'rgba(0, 0, 0, 0)',
                        opacity: 1,
                        justifyContent: 'center',
                        alignItems: 'center',
                        borderRadius: 7
                    }}>
                        <ActivityIndicator size="large" color="#FFF" />
                        <Text style={{ marginLeft: 10, color: '#FF', marginTop: 10 }}>正在加载...</Text>
                    </View>
                </View>
            )
        } else {
            return <View />
        }
    }
}

const styles = StyleSheet.create({
    LoadingPage: {
        position: 'absolute',
        left: 0,
        top: 0,
        backgroundColor: 'rgba(0, 0, 0, 0)',
        width: width,
        height: height,
        justifyContent: 'center',
        alignItems: 'center'
    }
})